﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business.IManager;
using Entity;
using Business.Manager;

namespace OnlinePayment.OP
{
    public partial class RecharchStuCard : System.Web.UI.Page
    {
        IStuCardManager stuCardManager = new StuCardManager();
        IOrderManager orderManager = new OrderManager();
        StudentCartHistoryOrder order = new StudentCartHistoryOrder();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                /*if (Session["User"] == null)
                {
                    Response.Redirect("/Account/LogIn.aspx");
                }
                else
                {
                    stu = (Student)Session["User"];
                    lblStuID.Text = stu.StudentId;
                }*/
                StuCardInforBind();
            }
        }

        private void StuCardInforBind()
        {
            //string stuId = (Master.Master.FindControl("lblStudentId") as Label).Text;
            Student stu = (Student)Session["User"];
            string stuId = stu.StudentId;
            string infor = stuCardManager.getStuCardInfor(stuId);
            lblStuIdCardNum.Text = infor.Substring(0, 14);
            lblRestAmount.Text = infor.Substring(14, infor.Length - 14);
        }

        protected void btnRecharch_Click(object sender, EventArgs e)
        {
            order.OrderDate = System.DateTime.Now;
            order.TotalAmount = Decimal.Parse(txtRecharchAmount.Text);
            order.PaymentType = "一卡通";
            order.stuCardId = lblStuIdCardNum.Text;
            order.OrderId = orderManager.getOrderId(order.PaymentType);
            Session["GoodsID"] = Convert.ToString(order.stuCardId);
            Session["Order"] = order;
            Response.Redirect("OrderConfirmView.aspx");
        }
    }
}